package com.jnu.myAccount.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.jnu.myAccount.R;
import com.jnu.myAccount.databinding.ActivityDetailBinding;
import com.jnu.myAccount.databinding.ActivityEditBinding;
import com.jnu.myAccount.record.Record;

public class DetailActivity extends AppCompatActivity {

    private Intent detailIntent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityDetailBinding activityDetailBinding = ActivityDetailBinding.inflate(getLayoutInflater());
        setContentView(activityDetailBinding.getRoot());
        detailIntent = getIntent();

        //监听返回按钮点击事件
        activityDetailBinding.back.setOnClickListener(v -> {
            setResult(RESULT_CANCELED, detailIntent);
            finish();
        });

        TextView text_fundValue = activityDetailBinding.detailValue;
        TextView text_type = activityDetailBinding.detailType;
        TextView text_inout = activityDetailBinding.detailInout;
        TextView text_account = activityDetailBinding.detailAccount;
        TextView text_date = activityDetailBinding.detailDate;
        TextView text_balance = activityDetailBinding.detailBalance;

        Float fundValue = detailIntent.getFloatExtra("fundValue",0);
        String type = detailIntent.getStringExtra("type");
        String inout = detailIntent.getBooleanExtra("inout", true) ? "收入":"支出";
        String account = detailIntent.getStringExtra("account");
        Float balance = detailIntent.getFloatExtra("balance",0);

        text_fundValue.setText(fundValue+"");
        text_type.setText(type);
        text_inout.setText(inout);
        text_account.setText(account);
        text_balance.setText(balance+"");
    }



}